package cn.jdy.anquan.web;

import java.util.HashMap;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.jdy.anquan.entity.SiteBook;
import cn.jdy.anquan.service.SiteBookService;
import cn.jdy.common.ctrl.BaseCtrl;
import cn.jdy.framework.log.BaseLog;
import cn.jdy.framework.util.DateUtil;

@Controller
@RequestMapping("/siteBook")
public class SiteBookCtrl extends BaseCtrl {
  @Autowired
  private SiteBookService siteBookService;
  
  @RequestMapping(value = "/save", method = RequestMethod.POST)
  @ResponseBody
  public Map<String, Object> saveSiteBook(SiteBook siteBook){
    Map<String, Object> jsonMap = new HashMap<String, Object>();
    try {
      siteBook.setIp(request.getRemoteAddr());
      siteBook.setCreateTime(DateUtil.getCurrentDate2());
      siteBook.setStatus("1");
      siteBookService.save(siteBook);
      jsonMap.put("status", 200);
    } catch (Exception e) {
      jsonMap.put("status", 500);
      BaseLog.e(this.getClass(), "保存留言信息失败", e);
    }
    return jsonMap;
  }
}
